package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.dto.SetmealPageDTO;
import com.sky.entity.Setmeal;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface SetmealMapper {



    // 根据菜品id修改套餐状态
    @Update("update setmeal set status=0 where id in(select setmeal_id from setmeal_dish where dish_id=#{dishId})")
    void updateStatusByDishId(Long dishId);

    //通过分类id统计
    String count = "SELECT count(*) FROM setmeal WHERE category_id=#{categoryId}";
    @Select(count)
    Integer count(Long categoryId);

    // 保存套餐
    void insert(Setmeal setmeal);

    // 查询list（条件）
    List<SetmealVO> getList(SetmealPageDTO setmealPageDTO);

    // 根据id查询
    @Select("select * from setmeal where id=#{id}")
    Setmeal getById(Long id);

    @AutoFill("update")
    void updateById(Setmeal setmeal);


    // 根据id删除套餐
    @Delete("delete from setmeal where id = #{id}")
    void deleteById(Long setmealId);


}
